VBD.type field, and add it to the C bindings (this was already in Xend).
Signed-off-by: Ewan Mellor <ewan@xensource.com>
{\tt SR} & A storage repository \\
{\tt VDI} & A virtual disk image \\
{\tt VBD} & A virtual block device \\
+{\tt VBD\_metrics} & The metrics associated with a virtual block device \\
{\tt PBD} & The physical block devices through which hosts access SRs \\
{\tt crashdump} & A VM crashdump \\
{\tt VTPM} & A virtual TPM device \\
$\mathit{RW}$ & {\tt bootable} & bool & true if this VBD is bootable \\
$\mathit{RW}$ & {\tt mode} & vbd\_mode & the mode the VBD should be mounted with \\
$\mathit{RW}$ & {\tt type} & vbd\_type & how the VBD will appear to the guest (e.g. disk or CD) \\
-$\mathit{RO}_\mathit{run}$ & {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
-$\mathit{RO}_\mathit{run}$ & {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
+$\mathit{RO}_\mathit{run}$ & {\tt metrics} & VBD\_metrics ref & metrics associated with this VBD. \\
\hline
\end{longtable}
\subsection{Additional RPCs associated with class: VBD}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_io\_read\_kbs}
+\subsubsection{RPC name:~get\_metrics}
{\bf Overview:}
-Get the io/read\_kbs field of the given VBD.
+Get the metrics field of the given VBD.
\noindent {\bf Signature:}
-\begin{verbatim} float get_io_read_kbs (session_id s, VBD ref self)\end{verbatim}
+\begin{verbatim} (VBD_metrics ref) get_metrics (session_id s, VBD ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-float
+VBD\_metrics ref
}
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~get\_io\_write\_kbs}
+\subsubsection{RPC name:~create}
{\bf Overview:}
-Get the io/write\_kbs field of the given VBD.
+Create a new VBD instance, and return its handle.
\noindent {\bf Signature:}
-\begin{verbatim} float get_io_write_kbs (session_id s, VBD ref self)\end{verbatim}
+\begin{verbatim} (VBD ref) create (session_id s, VBD record args)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD record } & args & All constructor arguments \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+VBD ref
+}
+
+
+reference to the newly created object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~destroy}
+
+{\bf Overview:}
+Destroy the specified VBD instance.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} void destroy (session_id s, VBD ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-float
+void
}
-value of the field
+
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~create}
+\subsubsection{RPC name:~get\_by\_uuid}
{\bf Overview:}
-Create a new VBD instance, and return its handle.
+Get a reference to the VBD instance with the specified UUID.
\noindent {\bf Signature:}
-\begin{verbatim} (VBD ref) create (session_id s, VBD record args)\end{verbatim}
+\begin{verbatim} (VBD ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
\noindent{\bf Arguments:}
\begin{tabular}{|c|c|p{7cm}|}
\hline
{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD record } & args & All constructor arguments \\ \hline
+{\tt string } & uuid & UUID of object to return \\ \hline
\end{tabular}
}
-reference to the newly created object
+reference to the object
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
-\subsubsection{RPC name:~destroy}
+\subsubsection{RPC name:~get\_record}
{\bf Overview:}
-Destroy the specified VBD instance.
+Get a record containing the current state of the given VBD.
\noindent {\bf Signature:}
-\begin{verbatim} void destroy (session_id s, VBD ref self)\end{verbatim}
+\begin{verbatim} (VBD record) get_record (session_id s, VBD ref self)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-void
+VBD record
}
+all fields from the object
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+
+\vspace{1cm}
+\newpage
+\section{Class: VBD\_metrics}
+\subsection{Fields for class: VBD\_metrics}
+\begin{longtable}{|lllp{0.38\textwidth}|}
+\hline
+\multicolumn{1}{|l}{Name} & \multicolumn{3}{l|}{\bf VBD\_metrics} \\
+\multicolumn{1}{|l}{Description} & \multicolumn{3}{l|}{\parbox{11cm}{\em
+The metrics associated with a virtual block device.}} \\
+\hline
+Quals & Field & Type & Description \\
+\hline
+$\mathit{RO}_\mathit{run}$ & {\tt uuid} & string & unique identifier/object reference \\
+$\mathit{RO}_\mathit{run}$ & {\tt io/read\_kbs} & float & Read bandwidth (KiB/s) \\
+$\mathit{RO}_\mathit{run}$ & {\tt io/write\_kbs} & float & Write bandwidth (KiB/s) \\
+\hline
+\end{longtable}
+\subsection{Additional RPCs associated with class: VBD\_metrics}
+\subsubsection{RPC name:~get\_uuid}
+
+{\bf Overview:}
+Get the uuid field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} string get_uuid (session_id s, VBD_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD\_metrics ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+string
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_io\_read\_kbs}
+
+{\bf Overview:}
+Get the io/read\_kbs field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} float get_io_read_kbs (session_id s, VBD_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD\_metrics ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+float
+}
+
+
+value of the field
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_io\_write\_kbs}
+
+{\bf Overview:}
+Get the io/write\_kbs field of the given VBD\_metrics.
+
+ \noindent {\bf Signature:}
+\begin{verbatim} float get_io_write_kbs (session_id s, VBD_metrics ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VBD\_metrics ref } & self & reference to the object \\ \hline
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:}
+{\tt
+float
+}
+
+
+value of the field
\vspace{0.3cm}
\vspace{0.3cm}
\vspace{0.3cm}
\subsubsection{RPC name:~get\_by\_uuid}
{\bf Overview:}
-Get a reference to the VBD instance with the specified UUID.
+Get a reference to the VBD\_metrics instance with the specified UUID.
\noindent {\bf Signature:}
-\begin{verbatim} (VBD ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
+\begin{verbatim} (VBD_metrics ref) get_by_uuid (session_id s, string uuid)\end{verbatim}
\noindent{\bf Arguments:}
\noindent {\bf Return Type:}
{\tt
-VBD ref
+VBD\_metrics ref
}
\subsubsection{RPC name:~get\_record}
{\bf Overview:}
-Get a record containing the current state of the given VBD.
+Get a record containing the current state of the given VBD\_metrics.
\noindent {\bf Signature:}
-\begin{verbatim} (VBD record) get_record (session_id s, VBD ref self)\end{verbatim}
+\begin{verbatim} (VBD_metrics record) get_record (session_id s, VBD_metrics ref self)\end{verbatim}
\noindent{\bf Arguments:}
\begin{tabular}{|c|c|p{7cm}|}
\hline
{\bf type} & {\bf name} & {\bf description} \\ \hline
-{\tt VBD ref } & self & reference to the object \\ \hline
+{\tt VBD\_metrics ref } & self & reference to the object \\ \hline
\end{tabular}
\noindent {\bf Return Type:}
{\tt
-VBD record
+VBD\_metrics record
}
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_common.h"
#include "xen_vbd_decl.h"
+#include "xen_vbd_metrics_decl.h"
#include "xen_vbd_mode.h"
+#include "xen_vbd_type.h"
#include "xen_vdi_decl.h"
#include "xen_vm_decl.h"
char *image;
bool bootable;
enum xen_vbd_mode mode;
- double io_read_kbs;
- double io_write_kbs;
+ enum xen_vbd_type type;
+ struct xen_vbd_metrics_record_opt *metrics;
} xen_vbd_record;
/**
/**
- * Get the current state of the given VBD. !!!
+ * Get a record containing the current state of the given VBD.
*/
extern bool
xen_vbd_get_record(xen_session *session, xen_vbd_record **result, xen_vbd vbd);
/**
- * Get a reference to the object with the specified UUID. !!!
+ * Get a reference to the VBD instance with the specified UUID.
*/
extern bool
xen_vbd_get_by_uuid(xen_session *session, xen_vbd *result, char *uuid);
/**
- * Get the io/read_kbs field of the given VBD.
+ * Get the type field of the given VBD.
*/
extern bool
-xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd);
+xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd);
/**
- * Get the io/write_kbs field of the given VBD.
+ * Get the metrics field of the given VBD.
*/
extern bool
-xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
+xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd);
/**
xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
+/**
+ * Set the type field of the given VBD.
+ */
+extern bool
+xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type);
+
+
/**
* Change the media in the device for CDROM-like devices only. For
* other devices, detach the VBD and attach a new one
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_VBD_METRICS_H
+#define XEN_VBD_METRICS_H
+
+#include "xen_common.h"
+#include "xen_vbd_metrics_decl.h"
+
+
+/*
+ * The VBD_metrics class.
+ *
+ * The metrics associated with a virtual block device.
+ */
+
+
+/**
+ * Free the given xen_vbd_metrics. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_metrics_free(xen_vbd_metrics vbd_metrics);
+
+
+typedef struct xen_vbd_metrics_set
+{
+ size_t size;
+ xen_vbd_metrics *contents[];
+} xen_vbd_metrics_set;
+
+/**
+ * Allocate a xen_vbd_metrics_set of the given size.
+ */
+extern xen_vbd_metrics_set *
+xen_vbd_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_metrics_set_free(xen_vbd_metrics_set *set);
+
+
+typedef struct xen_vbd_metrics_record
+{
+ xen_vbd_metrics handle;
+ char *uuid;
+ double io_read_kbs;
+ double io_write_kbs;
+} xen_vbd_metrics_record;
+
+/**
+ * Allocate a xen_vbd_metrics_record.
+ */
+extern xen_vbd_metrics_record *
+xen_vbd_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_vbd_metrics_record, and all referenced values.
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_free(xen_vbd_metrics_record *record);
+
+
+typedef struct xen_vbd_metrics_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_vbd_metrics handle;
+ xen_vbd_metrics_record *record;
+ } u;
+} xen_vbd_metrics_record_opt;
+
+/**
+ * Allocate a xen_vbd_metrics_record_opt.
+ */
+extern xen_vbd_metrics_record_opt *
+xen_vbd_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_vbd_metrics_record_opt, and all referenced
+ * values. The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_opt_free(xen_vbd_metrics_record_opt *record_opt);
+
+
+typedef struct xen_vbd_metrics_record_set
+{
+ size_t size;
+ xen_vbd_metrics_record *contents[];
+} xen_vbd_metrics_record_set;
+
+/**
+ * Allocate a xen_vbd_metrics_record_set of the given size.
+ */
+extern xen_vbd_metrics_record_set *
+xen_vbd_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_record_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_set_free(xen_vbd_metrics_record_set *set);
+
+
+
+typedef struct xen_vbd_metrics_record_opt_set
+{
+ size_t size;
+ xen_vbd_metrics_record_opt *contents[];
+} xen_vbd_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_vbd_metrics_record_opt_set of the given size.
+ */
+extern xen_vbd_metrics_record_opt_set *
+xen_vbd_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_metrics_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_vbd_metrics_record_opt_set_free(xen_vbd_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record **result, xen_vbd_metrics vbd_metrics);
+
+
+/**
+ * Get a reference to the VBD_metrics instance with the specified UUID.
+ */
+extern bool
+xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result, char *uuid);
+
+
+/**
+ * Get the uuid field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics vbd_metrics);
+
+
+/**
+ * Get the io/read_kbs field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics);
+
+
+/**
+ * Get the io/write_kbs field of the given VBD_metrics.
+ */
+extern bool
+xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics);
+
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_VBD_METRICS_DECL_H
+#define XEN_VBD_METRICS_DECL_H
+
+typedef void *xen_vbd_metrics;
+
+struct xen_vbd_metrics_set;
+struct xen_vbd_metrics_record;
+struct xen_vbd_metrics_record_set;
+struct xen_vbd_metrics_record_opt;
+struct xen_vbd_metrics_record_opt_set;
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_VBD_TYPE_H
+#define XEN_VBD_TYPE_H
+
+
+#include "xen_common.h"
+
+
+enum xen_vbd_type
+{
+ /**
+ * VBD will appear to guest as CD
+ */
+ XEN_VBD_TYPE_CD,
+
+ /**
+ * VBD will appear to guest as disk
+ */
+ XEN_VBD_TYPE_DISK
+};
+
+
+typedef struct xen_vbd_type_set
+{
+ size_t size;
+ enum xen_vbd_type contents[];
+} xen_vbd_type_set;
+
+/**
+ * Allocate a xen_vbd_type_set of the given size.
+ */
+extern xen_vbd_type_set *
+xen_vbd_type_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vbd_type_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vbd_type_set_free(xen_vbd_type_set *set);
+
+
+/**
+ * Return the name corresponding to the given code. This string must
+ * not be modified or freed.
+ */
+extern const char *
+xen_vbd_type_to_string(enum xen_vbd_type val);
+
+
+/**
+ * Return the correct code for the given string, or set the session
+ * object to failure and return an undefined value if the given string does
+ * not match a known code.
+ */
+extern enum xen_vbd_type
+xen_vbd_type_from_string(xen_session *session, const char *str);
+
+
+#endif
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+/*
+ * Declarations of the abstract types used during demarshalling of enum
+ * xen_vbd_type. Internal to this library -- do not use from outside.
+ */
+
+
+#ifndef XEN_VBD_TYPE_INTERNAL_H
+#define XEN_VBD_TYPE_INTERNAL_H
+
+
+#include "xen_internal.h"
+
+
+extern const abstract_type xen_vbd_type_abstract_type_;
+extern const abstract_type xen_vbd_type_set_abstract_type_;
+
+
+#endif
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
#include "xen_common.h"
#include "xen_internal.h"
#include "xen_vbd.h"
+#include "xen_vbd_metrics.h"
#include "xen_vbd_mode_internal.h"
+#include "xen_vbd_type_internal.h"
#include "xen_vdi.h"
#include "xen_vm.h"
{ .key = "mode",
.type = &xen_vbd_mode_abstract_type_,
.offset = offsetof(xen_vbd_record, mode) },
- { .key = "io_read_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_vbd_record, io_read_kbs) },
- { .key = "io_write_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_vbd_record, io_write_kbs) }
+ { .key = "type",
+ .type = &xen_vbd_type_abstract_type_,
+ .offset = offsetof(xen_vbd_record, type) },
+ { .key = "metrics",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_vbd_record, metrics) }
};
const abstract_type xen_vbd_record_abstract_type_ =
xen_vm_record_opt_free(record->vm);
xen_vdi_record_opt_free(record->vdi);
free(record->device);
+ xen_vbd_metrics_record_opt_free(record->metrics);
free(record);
}
};
abstract_type result_type = xen_vbd_mode_abstract_type_;
- char *result_str = NULL;
XEN_CALL_("VBD.get_mode");
- *result = xen_vbd_mode_from_string(session, result_str);
return session->ok;
}
bool
-xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd)
+xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd)
{
abstract_value param_values[] =
{
.u.string_val = vbd }
};
- abstract_type result_type = abstract_type_float;
-
- XEN_CALL_("VBD.get_io_read_kbs");
+ abstract_type result_type = xen_vbd_type_abstract_type_;
+ XEN_CALL_("VBD.get_type");
return session->ok;
}
bool
-xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd)
+xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd)
{
abstract_value param_values[] =
{
.u.string_val = vbd }
};
- abstract_type result_type = abstract_type_float;
+ abstract_type result_type = abstract_type_string;
- XEN_CALL_("VBD.get_io_write_kbs");
+ *result = NULL;
+ XEN_CALL_("VBD.get_metrics");
return session->ok;
}
}
+bool
+xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd },
+ { .type = &xen_vbd_type_abstract_type_,
+ .u.string_val = xen_vbd_type_to_string(type) }
+ };
+
+ xen_call_(session, "VBD.set_type", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
bool
xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi)
{
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_internal.h"
+#include "xen_vbd_metrics.h"
+
+
+XEN_FREE(xen_vbd_metrics)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics)
+XEN_ALLOC(xen_vbd_metrics_record)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics_record)
+XEN_ALLOC(xen_vbd_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_vbd_metrics)
+XEN_SET_ALLOC_FREE(xen_vbd_metrics_record_opt)
+
+
+static const struct_member xen_vbd_metrics_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_vbd_metrics_record, uuid) },
+ { .key = "io_read_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_vbd_metrics_record, io_read_kbs) },
+ { .key = "io_write_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_vbd_metrics_record, io_write_kbs) }
+ };
+
+const abstract_type xen_vbd_metrics_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_vbd_metrics_record),
+ .member_count =
+ sizeof(xen_vbd_metrics_record_struct_members) / sizeof(struct_member),
+ .members = xen_vbd_metrics_record_struct_members
+ };
+
+
+void
+xen_vbd_metrics_record_free(xen_vbd_metrics_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ free(record);
+}
+
+
+bool
+xen_vbd_metrics_get_record(xen_session *session, xen_vbd_metrics_record **result, xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = xen_vbd_metrics_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("VBD_metrics.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_by_uuid(xen_session *session, xen_vbd_metrics *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VBD_metrics.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_io_read_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("VBD_metrics.get_io_read_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_io_write_kbs(xen_session *session, double *result, xen_vbd_metrics vbd_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vbd_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("VBD_metrics.get_io_write_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_vbd_metrics_get_uuid(xen_session *session, char **result, xen_vbd_metrics vbd_metrics)
+{
+ *result = session->ok ? xen_strdup_((char *)vbd_metrics) : NULL;
+ return session->ok;
+}
--- /dev/null
+/*
+ * Copyright (c) 2006-2007, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <string.h>
+
+#include "xen_internal.h"
+#include "xen_vbd_type.h"
+#include "xen_vbd_type_internal.h"
+
+
+/*
+ * Maintain this in the same order as the enum declaration!
+ */
+static const char *lookup_table[] =
+{
+ "CD",
+ "Disk"
+};
+
+
+extern xen_vbd_type_set *
+xen_vbd_type_set_alloc(size_t size)
+{
+ return calloc(1, sizeof(xen_vbd_type_set) +
+ size * sizeof(enum xen_vbd_type));
+}
+
+
+extern void
+xen_vbd_type_set_free(xen_vbd_type_set *set)
+{
+ free(set);
+}
+
+
+const char *
+xen_vbd_type_to_string(enum xen_vbd_type val)
+{
+ return lookup_table[val];
+}
+
+
+extern enum xen_vbd_type
+xen_vbd_type_from_string(xen_session *session, const char *str)
+{
+ return ENUM_LOOKUP(session, str, lookup_table);
+}
+
+
+const abstract_type xen_vbd_type_abstract_type_ =
+ {
+ .typename = ENUM,
+ .enum_marshaller =
+ (const char *(*)(int))&xen_vbd_type_to_string,
+ .enum_demarshaller =
+ (int (*)(xen_session *, const char *))&xen_vbd_type_from_string
+ };
+
+
+const abstract_type xen_vbd_type_set_abstract_type_ =
+ {
+ .typename = SET,
+ .child = &xen_vbd_type_abstract_type_
+ };
+
+
_check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
'VBD', func, *args, **kwargs)
+def valid_vbd_metrics(func):
+ """Decorator to verify if ref is valid before calling method.
+
+ @param func: function with params: (self, session, ref, ...)
+ @rtype: callable object
+ """
+ return lambda *args, **kwargs: \
+ _check_ref(lambda r: XendDomain.instance().is_valid_dev('vbd', r),
+ 'VBD_metrics', func, *args, **kwargs)
+
def valid_vif(func):
"""Decorator to verify if vif_ref is valid before calling method.
'network' : valid_network,
'VM' : valid_vm,
'VBD' : valid_vbd,
+ 'VBD_metrics' : valid_vbd_metrics,
'VIF' : valid_vif,
'VDI' : valid_vdi,
'VTPM' : valid_vtpm,
# Xen API: Class VBD
# ----------------------------------------------------------------
- VBD_attr_ro = ['io_read_kbs',
- 'io_write_kbs']
+ VBD_attr_ro = ['metrics']
VBD_attr_rw = ['VM',
'VDI',
'device',
for k in cfg.keys():
if k in valid_vbd_keys:
return_cfg[k] = cfg[k]
-
+
+ return_cfg['metrics'] = vbd_ref
+
return xen_api_success(return_cfg)
def VBD_media_change(self, session, vbd_ref, vdi_ref):
XendTask.log_progress(0, 100, vm.destroy_vbd, vbd_ref)
return xen_api_success_void()
- # attributes (rw)
def _VBD_get(self, vbd_ref, prop):
return xen_api_success(
XendDomain.instance().get_dev_property_by_uuid(
'vbd', vbd_ref, prop))
+ # attributes (ro)
+ def VBD_get_metrics(self, _, vbd_ref):
+ return xen_api_success(vbd_ref)
+
+ # attributes (rw)
def VBD_get_VM(self, session, vbd_ref):
return self._VBD_get(vbd_ref, 'VM')
def VBD_get_type(self, session, vbd_ref):
return self._VBD_get(vbd_ref, 'type')
- def VBD_get_io_read_kbs(self, session, vbd_ref):
- return self._VBD_get(vbd_ref, 'io_read_kbs')
-
- def VBD_get_io_write_kbs(self, session, vbd_ref):
- return self._VBD_get(vbd_ref, 'io_write_kbs')
-
def VBD_set_bootable(self, session, vbd_ref, bootable):
bootable = bool(bootable)
xd = XendDomain.instance()
vbds = reduce(lambda x, y: x + y, vbds)
return xen_api_success(vbds)
+
+ # Xen API: Class VBD_metrics
+ # ----------------------------------------------------------------
+
+ VBD_metrics_attr_ro = ['io_read_kbs',
+ 'io_write_kbs']
+ VBD_metrics_attr_rw = []
+ VBD_methods = []
+
+ def VBD_metrics_get_record(self, _, ref):
+ vm = XendDomain.instance().get_vm_with_dev_uuid('vbd', ref)
+ if not vm:
+ return xen_api_error(['HANDLE_INVALID', 'VBD_metrics', ref])
+ return xen_api_success(
+ { 'io_read_kbs' : vm.get_dev_property('vbd', ref, 'io_read_kbs'),
+ 'io_write_kbs' : vm.get_dev_property('vbd', ref, 'io_write_kbs') })
+
+ def VBD_metrics_get_io_write_kbs(self, _, ref):
+ return self._VBD_get(ref, 'io_read_kbs')
+
+ def VBD_metrics_get_io_write_kbs(self, session, vbd_ref):
+ return self._VBD_get(ref, 'io_write_kbs')
+
+
# Xen API: Class VIF
# ----------------------------------------------------------------